package components {
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	import mx.controls.Button;
	import mx.effects.Resize;
	import mx.events.FlexEvent;
	import mx.modules.ModuleLoader;

	public class InfoPanel extends Canvas {
		
		//------------------------------------------------------------
        //
        // class constants
        //
        //------------------------------------------------------------
        
        /**
         * the final width of penal, after effect finished
         */
        public static const FINAL_WIDTH:int = 400;
        
        /**
         * the initial width of penal, before effect start
         */
        public static const INIT_WIDTH:int = 0;
        
        public static const COMPANYINFO_MODULE:String = "CompanyInfoModule.swf";
        public static const ADMIN_MODULE:String = "AdminModule.swf";
        public static const ADMIN_LOGIN_MODULE:String = "AdminLoginModule.swf";
        
        //------------------------------------------------------------
        //
        // object vaiables
        //
        //------------------------------------------------------------
        
        private var _showET:Resize;
        private var _hideET:Resize;
        
        private var _ml:ModuleLoader;
        
        //------------------------------
        // moduleLoader
        //------------------------------

        /**
         * module loader for company, administrator and login etc. module
         */
        private var _moduleLoader:ModuleLoader;

        public function get moduleLoader():ModuleLoader {
            return _moduleLoader;
        }
        
        //------------------------------------------------------------
        //
        // methods
        //
        //------------------------------------------------------------
        
        /**
         * navigate to assigned url
         * @param url specify module path and name
         */
        public function navigateTo(url:String):void {
        	moduleLoader.url = "";
        	moduleLoader.url = url;
        }
        
        //------------------------------------------------------------
        //
        // constructor
        //
        //------------------------------------------------------------
		
		public function InfoPanel() {
			super();
			
			// initialize effect objects
			_showET = new Resize();
			_showET.duration = 300;
			_showET.widthBy = FINAL_WIDTH;
			
			_hideET = new Resize();
			_hideET.duration = 300;
            _hideET.widthBy = -FINAL_WIDTH;
            
            setStyle("showEffect", _showET);
            setStyle("hideEffect", _hideET);
            
            // initialize module loader
            _moduleLoader = new ModuleLoader();
            _moduleLoader.percentWidth = 100;
            _moduleLoader.percentHeight = 100;
            _moduleLoader.x = 2;
            
            horizontalScrollPolicy = "off";
            verticalScrollPolicy = "off";
            
            addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
		}
		
		//------------------------------------------------------------
        //
        // event handlers
        //
        //------------------------------------------------------------
        
        private function onCreationComplete(e:FlexEvent):void {
            addChild(_moduleLoader);
        }
	
	}
}